package net.lab1024.sa.admin.module.business.cutting.controller;

import net.lab1024.sa.admin.module.business.cutting.domain.form.CuttingInfoAddForm;
import net.lab1024.sa.admin.module.business.cutting.domain.form.CuttingInfoQueryForm;
import net.lab1024.sa.admin.module.business.cutting.domain.form.CuttingInfoUpdateForm;
import net.lab1024.sa.admin.module.business.cutting.domain.vo.CuttingInfoVO;
import net.lab1024.sa.admin.module.business.cutting.service.CuttingInfoService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;

/**
 * 下料表 Controller
 *
 * @Author zzx
 * @Date 2025-08-08 19:37:29
 * @Copyright zzx
 */

@RestController
@Tag(name = "下料表")
public class CuttingInfoController {

    @Resource
    private CuttingInfoService cuttingInfoService;

    @Operation(summary = "分页查询 @author zzx")
    @PostMapping("/cuttingInfo/queryPage")
    @SaCheckPermission("cuttingInfo:query")
    public ResponseDTO<PageResult<CuttingInfoVO>> queryPage(@RequestBody @Valid CuttingInfoQueryForm queryForm) {
        return ResponseDTO.ok(cuttingInfoService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author zzx")
    @PostMapping("/cuttingInfo/add")
    @SaCheckPermission("cuttingInfo:add")
    public ResponseDTO<String> add(@RequestBody @Valid CuttingInfoAddForm addForm) {
        return cuttingInfoService.add(addForm);
    }

    @Operation(summary = "更新 @author zzx")
    @PostMapping("/cuttingInfo/update")
    @SaCheckPermission("cuttingInfo:update")
    public ResponseDTO<String> update(@RequestBody @Valid CuttingInfoUpdateForm updateForm) {
        return cuttingInfoService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author zzx")
    @PostMapping("/cuttingInfo/batchDelete")
    @SaCheckPermission("cuttingInfo:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return cuttingInfoService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author zzx")
    @GetMapping("/cuttingInfo/delete/{cuttingId}")
    @SaCheckPermission("cuttingInfo:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Long cuttingId) {
        return cuttingInfoService.delete(cuttingId);
    }

    @Operation(summary = "详情 @author zzx")
    @GetMapping("/cuttingInfo/sortDetail/{cuttingId}")
    @SaCheckPermission("cuttingInfo:sortDetail")
    public ResponseDTO<CuttingInfoVO> sortDetail(@PathVariable Long cuttingId) {
        return cuttingInfoService.sortDetail(cuttingId);
    }
}
